import java.util.Arrays;

public class Text2 {
    private int[]arr;
    int usesize;
    public Text2(){
        arr=new int[]{1,3,5,7,9};
    }
    public void add(int val){
        expansion();
        arr[usesize++]=val;
    }
    public void addsore(int val)throws indexException{
        expansion();
        int pos=-1;
        for (int i = 0; i < usesize; i++) {
            if(val<arr[i]){
                pos=i;
                break;
            }
        }
        for (int i = usesize-1; i>=pos ; i--) {
            arr[i+1]=arr[i];
        }
        arr[pos]=val;
        usesize++;
    }
    public  void expansion(){
        if(isfull()){
            arr= Arrays.copyOf(arr,2*arr.length);
        }
    }
    public boolean isfull(){
        return arr.length==usesize;
    }
    public boolean empty(){
        return usesize==0;
    }
    public void dissplay(){
        for (int i = 0; i < usesize; i++) {
            System.out.print(arr[i]+" ");
        }
    }
}
